{from Thomas Seebacher  un691ts@genius.embnet.dkfz-heidelberg.de}{Estimates the molecular weight of DNA restriction fragments or proteins}{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   IMPORTANT    !!!!!!!!!!!!!!!!!!!!!!!!!!!!}{********     Assumes the gel to run from top to bottom            *********}{*********only the y-coordinates were used for the calculation*******}{Count the number of bands in the reference lane you want to include as MW reference}{Calibrate the gel first by entering the number of MW reference bands you want to include in your MW calibration curve}{The macro gets the Y-coordinate for each band by mouse click and you must enter for each band their known molecular weight}{the measurement counter was set to the position after the selected reference bands}varleft,top,width,height,lower,upper,nm,n,m,x,y,z,MW,Pic1,Pic2,Pic3,i,j:integer;nval, MWeight:string;Procedure click;begin;SetCursor('cross');repeat until button;end;Procedure error1;begin;putMessage('Two different  reference bands have the same y coordinate');exit;end;Procedure Fwert;begin;n:=rMean[1];if y<=rY[1] then	begin   {Out of range of  lower reference band};if ((rY[2]-rY[1])=0) then error1;   	MW:=rUser2[1]-(rUser2[2]-rUser2[1])*(rY[1]-y)/(rY[2]-rY[1]);   MW:=exp(MW);end;if y>=rY[n] thenbegin   {Out of range of upper reference band};if ((rY[n]-rY[n-1])=0) then error1;   	MW:=rUser2[n]+(rUser2[n]-rUser2[n-1])*(y-rY[n])/(rY[n]-rY[n-1]);   MW:=exp(MW);end;if (rY[1]< y) AND (y < rY[n]) thenbegin			i:=0;  {selects the nearest reference bands};			repeat;					i:=i+1;			until  rY[i]>y;if ((rY[i]-rY[i-1])=0) then error1;				MW:=rUser2[i]-(rUser2[i]-rUser2[i-1])*(rY[i]-y)/(rY[i]-rY[i-1]);				MW:=exp(MW);	end;end;Procedure Interpolate;begin;SetOptions( 'X-Y Center,User1');{ShowMessage('Click mouse button to stop','\','\Y=  ',y:6:0,'\MW= ',MW:6:0);}repeat;   SetCursor('cross');  GetMouse(x,y);  Fwert;  ShowMessage('Click mouse button to stop','\','\X= ',x:6:0,'\Y=  ',y:6:0,'\MW= ',MW:6:0);  wait(0.3);until button;end;Macro 'MW calibrate the gel with standards';begin;rMean[2]:=0;ResetCounter;SetCounter(1);nval:=GetString('Number of reference bands=');SelectWindow(WindowTitle);n:=StringToNum(nval);ShowMessage('n values=',n);if n<2 thenbegin   PutMessage('You must enter at least 2 reference bands');   exit;end;For m:=1 to n dobegin     SetCounter(m);     ShowMessage('Click on reference band ',m);      click;     GetMouse(x,y);     rX[m]:=x;{stores the y-coordinate of the reference band in rY array}     rY[m]:=y;     MWeight:=GetString('Molecular weight  = ');     MW:=StringToNum(MWeight);     rUser1[m]:=MW;     rLength[m]:=MW;{stores the log of the reference bands MW in the User2 array}     rUser2[m]:=ln(MW);    SelectWindow(WindowTitle);    rMean[1]:=n;end;rMean[2]:=1;SetCursor('arrow');ShowMessage('Finished with reference band selection');end;Macro 'Continuous measurement  loop';begin;if (rMean[2]=0) thenbegin;  PutMessage('Enter  MW standards for your  gel');   exit;end;SetCursor('cross');repeat;     Interpolate;until button;end;Macro 'Measure the MW of selected bands';begin;if ( rMean[2]=0) thenbegin;  PutMessage('Enter  MW standards for your  gel');   exit;end;n:=rMean[1];nm:=n;repeat;     ShowMessage('Click on band of interest');     SetCursor('cross');     if (nm<>n) then ShowMessage('Press option key','\and click mouse button to stop','\X= ',x:6:0,'\Y=  ',y:6:0,'\MW= ',MW:6:0,'\Band#= ',rCount-n);     Wait(1);     click;    GetMouse(x,y);    nm:=nm+1;    Fwert;   SetCounter(nm);    rUser1[nm]:=MW;   rX[nm]:=x;  	rY[nm]:=y;  UpdateResults;until KeyDown('option');SetCounter(nm-1);SetUser1Label('MW');SetOptions( 'X-Y Center,User1');ShowResults;end;end.